/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.storebits.testsystem;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author Ventsi
 */
@Entity
@Table(name = "carreservation")
@NamedQueries({
    @NamedQuery(name = "Carreservation.findAll", query = "SELECT c FROM Carreservation c")})
public class Carreservation implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "pickUpDate")
    @Temporal(TemporalType.DATE)
    private Date pickUpDate;
    @NotNull
    @Column(name = "dropOffDate")
    @Temporal(TemporalType.DATE)
    private Date dropOffDate;
    @JoinColumn(name = "pickUpLocation", referencedColumnName = "idPickUpLocation")
    @ManyToOne(optional = false)
    private Pickuplocation pickUpLocation;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idCarReservation")
    private Integer idCarReservation = new Integer(0);
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "deposit")
    private BigDecimal deposit = new BigDecimal(0);
    @Basic(optional = false)
    @NotNull
    @Column(name = "totalSum")
    private BigDecimal totalSum = new BigDecimal(0);
    @JoinColumn(name = "car", referencedColumnName = "registrationNumber")
    @ManyToOne(optional = false)
    private Car car;
    @JoinColumn(name = "customer", referencedColumnName = "USERNAME")
    @OneToOne(optional = false)
    private Users customer;

    public Carreservation() {
    }

    public Carreservation(Integer idCarReservation) {
        this.idCarReservation = idCarReservation;
    }

    public Carreservation(Date pickUpDate, Pickuplocation pickUpLocation, Car car) {
        this.pickUpDate = pickUpDate;
        this.pickUpLocation = pickUpLocation;
        this.car = car;
    }

    public Carreservation(Date pickUpDate, Pickuplocation pickUpLocation, Car car, Users user) {
        this.pickUpDate = pickUpDate;
        this.pickUpLocation = pickUpLocation;
        this.car = car;
        this.customer = user;
    }

    public Integer getIdCarReservation() {
        return idCarReservation;
    }

    public void setIdCarReservation(Integer idCarReservation) {
        this.idCarReservation = idCarReservation;
    }
    
    public BigDecimal getDeposit() {
        return deposit;
    }

    public void setDeposit(BigDecimal deposit) {
        this.deposit = deposit;
    }

    public Car getCar() {
        return car;
    }

    public void setCar(Car car) {
        this.car = car;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCarReservation != null ? idCarReservation.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Carreservation)) {
            return false;
        }
        Carreservation other = (Carreservation) object;
        if ((this.idCarReservation == null && other.idCarReservation != null) || (this.idCarReservation != null && !this.idCarReservation.equals(other.idCarReservation))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.storebits.testsystem.Carreservation[ idCarReservation=" + idCarReservation + " ]";
    }

    public Pickuplocation getPickUpLocation() {
        return pickUpLocation;
    }

    public void setPickUpLocation(Pickuplocation pickUpLocation) {
        System.out.println("setPickUpLocation(" + pickUpLocation + ")");
        this.pickUpLocation = pickUpLocation;
    }

    public Date getPickUpDate() {
        return pickUpDate;
    }

    public void setPickUpDate(Date pickUpDate) {
        this.pickUpDate = pickUpDate;
    }

    public Users getCustomer() {
        return customer;
    }

    public void setCustomer(Users customer) {
        this.customer = customer;
    }

    public void setDropOffDate(Date dropOffDate) {
        System.out.println("setDropOffDate");
        this.dropOffDate = dropOffDate;
    }

    public Date getDropOffDate() {
        return dropOffDate;
    }

    public void setTotalSum(BigDecimal totalSum) {
        this.totalSum = totalSum;
    }

    public BigDecimal getTotalSum() {
        return totalSum;
    }
}
